package com.hycat.mail.cart.vo;

import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author 吕泽浩业
 * @version 1.0
 */
@Data
public class CartItem implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long skuId;
    private Boolean check = true;
    private Boolean hasStock = true;
    private String title;
    private String image;
    private List<String> skuAttrs;
    private Integer count;
    private BigDecimal price;
    private BigDecimal totalPrice;
    private Date creatTime;
    private Date updateTime;

    public CartItem from(SkuInfoVo skuInfoEntity, Integer count) {
        this.creatTime = new Date();
        this.updateTime = new Date();
        this.hasStock = true;
        this.check = true;
        this.count = count;
        this.price = skuInfoEntity.getPrice();
        this.title = skuInfoEntity.getSkuTitle();
        this.image = skuInfoEntity.getSkuDefaultImg();
        this.skuId = skuInfoEntity.getSkuId();
        this.totalPrice = skuInfoEntity.getPrice().multiply(new BigDecimal(count));
        return this;
    }
}
